package manager;

import entity.PointType;
import iface.IManager;
import java.util.ArrayList;
/**
 *
 * @author Noi
 */
public class PointTypeManager implements IManager<PointType> {
    
    private ArrayList<PointType> pointTypeList;

    public PointTypeManager() {
        this.pointTypeList = new ArrayList<PointType>();
    }
    
    @Override
    public boolean add(PointType obj) {
        return this.pointTypeList.add(obj);
    }

    @Override
    public boolean remove(PointType obj) {
        return this.pointTypeList.remove(obj);
    }

    @Override
    public PointType replace(int index, PointType obj) {
        return this.pointTypeList.set(index, obj);
    }

    @Override
    public int size() {
        return this.pointTypeList.size();
    }

    @Override
    public PointType get(int index) {
        return this.pointTypeList.get(index);
    }

    @Override
    public PointType getById(int id) {
        for(PointType obj: this.pointTypeList) {
            if(obj.getPointTypeID() == id) return obj;
        }
        return null;
    }

    @Override
    public PointType getByName(String name) {
        for(PointType obj: this.pointTypeList) {
            if(obj.getPointName().equals(name)) return obj;
        }
        return null;
    }

    @Override
    public void setVisible(PointType obj, boolean value) {
        for(PointType object: this.pointTypeList) {
            if(obj.getPointTypeID() == object.getPointTypeID()) obj.setStatus(value);
        }
    }

}
